From 050f4be86316ce274297b9daa118ee9cf527f08c Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 29 Mar 2018 11:07:49 +0200 Subject: [PATCH] Move resolver Context initialization into a method --- src/cargo/core/resolver/context.rs | 11 +++++++++++ src/cargo/core/resolver/mod.rs | 11 ++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/cargo/core/resolver/context.rs b/src/cargo/core/resolver/context.rs index 215a8a98c..eaf7036d9 100644 --- a/src/cargo/core/resolver/context.rs +++ b/src/cargo/core/resolver/context.rs @@ -37,6 +37,17 @@ pub struct Context { } impl Context { + pub fn new() -> Context { + Context { + resolve_graph: RcList::new(), + resolve_features: HashMap::new(), + links: HashMap::new(), + resolve_replacements: RcList::new(), + activations: HashMap::new(), + warnings: RcList::new(), + } + } + /// Activate this summary by inserting it into our list of known activations. /// /// Returns true if this summary with the given method is already activated. diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index e72439b14..3b71af2a7 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -63,7 +63,7 @@ use util::profile; use self::context::{Activations, Context}; use self::types::{ActivateError, ActivateResult, Candidate, ConflictReason, DepsFrame, GraphNode}; -use self::types::{RcList, RcVecIter, RegistryQueryer}; +use self::types::{RcVecIter, RegistryQueryer}; pub use self::encode::{EncodableDependency, EncodablePackageId, EncodableResolve}; pub use self::encode::{Metadata, WorkspaceResolve}; @@ -113,14 +113,7 @@ pub fn resolve( config: Option<&Config>, print_warnings: bool, ) -> CargoResult { - let cx = Context { - resolve_graph: RcList::new(), - resolve_features: HashMap::new(), - links: HashMap::new(), - resolve_replacements: RcList::new(), - activations: HashMap::new(), - warnings: RcList::new(), - }; + let cx = Context::new(); let _p = profile::start("resolving"); let minimal_versions = match config { Some(config) => config.cli_unstable().minimal_versions, -- 2.30.2